package com.system.utils.excelutil;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 日志文件记录
 @author rzc zchcpy wxb */
public class OutPutTxt {
    /**
     当前util方法
     */
    public static void Log(String path, String fileName, String conent){
        conent = getNowTimeToSeconds() + "	" + conent;
        File fp = new File(path);
        // 创建目录
        if(!fp.exists()){
            fp.mkdirs();// 目录不存在的情况下，创建目录。
        }
        BufferedWriter out = null;
        try{
            path = path + fileName;
            out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path,true),"UTF-8"));
            out.write(conent);
            out.write("\n");
            out.flush();
        } catch(Exception e){
            e.printStackTrace();
        } finally{
            try{
                out.close();
            } catch(IOException e){
                e.printStackTrace();
            }
        }
    }
    public static String getNowTimeToSeconds() {
        // 设置日期格式
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        return df.format(new Date());
    }
    public static void main(String[] args) {
        Log("E:","charge.txt","1");
    }
}
